<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>04-伪数组添加索引？</title>
</head>
<body>
    <ul>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>
    <script>
        var li = document.getElementsByTagName("li")
        for(var i = 0;i<li.length;i++){
            li[i].index = i
            li[i].setAttribute("index2",i)
            li[i].onclick = function(){
                console.log(this.index)  // 得到的是 number 类型
                console.log(this.getAttribute("index2")) // 得到的是字符串类型
            }
            // console.log(li[i].index)
        }
        // console.log(li[0].__proto__.__proto__)
   
    </script>
</body>
</html>